Caroline & Luxi - VideoStoreAPI - Octos#9
Open
Lindseyls wants to merge 34 commits intoAda-C9:masterfrom
Open
Conversation
…d updated the testing for each method
…ated customers_controller_test.rb
…ckout method. Also, created the routes for rentals
…em to Gemfile but did not install
…te rental model validation tests
…d movie and customer validations
…mer business logic methods
…movie id's. Updated the check_in method in rental_controller.rb to update movie and customer inventory when the movie is checked back in
…oller to display available inventory
…hat we created for customer and movie. We updated the customer model with a new method for movies checked out count. Then, we updated the testing for both customer and movie models
…ated the testing for rental.rb and started the testing for the rentals controller
… rental controller
…rental#checkout controller method
| validates :phone, presence: true | ||
|
|
||
| def movies_checked_out_count | ||
| checked_out_count = Rental.where(customer_id: self.id, check_in: nil).count |
There was a problem hiding this comment.
You should be able to determine this using self.rentals rather than going through Rental.where
| validates :inventory, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } | ||
|
|
||
| def available_inventory | ||
| checked_out_count = Rental.where(movie_id: self.id, check_in: nil).count |
There was a problem hiding this comment.
Same comment re: going through self.rentals rather than Rental.where
|
|
||
| describe CustomersController do | ||
| describe "index" do | ||
| it "gets all the customers" do |
There was a problem hiding this comment.
It might be good to verify that this works when there are lots of customers as well as no customers
| @@ -0,0 +1,72 @@ | |||
| class RentalsController < ApplicationController | |||
|
|
|||
| RENTAL_LIMIT = 7 #days | |||
There was a problem hiding this comment.
This should really be a part of the model, not the controller.
| def check_out | ||
| rental = Rental.new(rental_params) | ||
| rental.check_out = DateTime.now | ||
| rental.due_date = rental.check_out + RENTAL_LIMIT |
There was a problem hiding this comment.
Moving the rental constant would probably also lead to moving this logic in the model as well
Video StoreWhat We're Looking For
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Video Store API
Congratulations! You're submitting your assignment!
If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.
Comprehension Questions